package com.fh.ms.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @FileName : RibbonConfig
 * @Description :
 * @Author : fh
 * @Date : 2020/11/19 11:27
 * @Version : 1.0.0
 */
@Configuration
public class RibbonConfig {

    /**
     * 初始化RestTemplate ribbon依赖RestTemplate实现远程调用
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public IRule iRule(){
        //轮询策略
        return new RoundRobinRule();
    }
}
